package jdbc.mysql.gzpowernode;

import java.sql.*;
import java.util.*;

public class test02 {
    public static void main(String[] args) {
        Connection conn = null;
        Statement stmt = null;
        ResourceBundle bundle = ResourceBundle.getBundle("jdbc");
        String driver = bundle.getString("driver");
        String url = bundle.getString("url");
        String user = bundle.getString("user");
        String password = bundle.getString("password");
        String sql = bundle.getString("sql");

        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, user, password);
            System.out.println("DatabaceObject = " + conn);
            stmt = conn.createStatement();
            int count = stmt.executeUpdate(sql);
            System.out.println(count == 1 ? "catching has suggested" : "catching have error");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (stmt != null) {
                    stmt.close();
                    System.out.println("stmt has closed");
                }
            } catch (SQLException e) {
                System.out.println("stmt can't closed");
                e.printStackTrace();

            }

            try {
                if (conn != null) {
                    conn.close();
                    System.out.println("conn has closed");
                }
            } catch (SQLException e) {
                System.out.println("conn can't closed");
                e.printStackTrace();

            }
        }


    }
}